package com.qf.controller;

import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @author zdl
 * @date 2025/2/21
 */
@RestController
@CrossOrigin
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping("/login")
    public R<User> loginByUser(@RequestBody User user, HttpSession session){
        //session.setAttribute("session",user);
        return R.ok(userService.loginByUser(user,session));
    }

    @PostMapping("/logout")
    public R<?> logout(HttpSession session){
        session.removeAttribute("login");
        return R.ok("退出成功");
    }

}
